﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web;

namespace FeatureCenter.Module.Web {
    public class RegisterCustomScriptsController : Controller {
        private void window_CustomRegisterTemplateDependentScripts(object sender, CustomRegisterTemplateDependentScriptsEventArgs e) {
            WebWindow window = (WebWindow)sender;
            e.Handled = true;
            e.Page.ClientScript.RegisterClientScriptResource(GetType(), "FeatureCenter.Module.Web.Resources.TemplateScripts.js");
            e.Page.ClientScript.RegisterClientScriptResource(GetType(), "FeatureCenter.Module.Web.Resources.MoveFooter.js");
        }
        protected override void OnFrameAssigned() {
            base.OnFrameAssigned();
            WebWindow window = Frame as WebWindow;
            if(window != null) {
                window.CustomRegisterTemplateDependentScripts += new EventHandler<CustomRegisterTemplateDependentScriptsEventArgs>(window_CustomRegisterTemplateDependentScripts);
            }
        }
        protected override void OnDeactivated() {
            WebWindow window = Frame as WebWindow;
            if(window != null) {
                window.CustomRegisterTemplateDependentScripts -= new EventHandler<CustomRegisterTemplateDependentScriptsEventArgs>(window_CustomRegisterTemplateDependentScripts);
            }
            base.OnDeactivated();
        }
    }
}
